﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Xml;

namespace SPVisualDev.VSAddin.Dialogs.PropertySheets
{
    internal class PropSheetModule : PropSheetBase
    {
        public PropSheetModule(string DefaultResourceFile, EnvDTE.ProjectItem ParentFeatureFolder, ElementInfo Element)
        {
            this.DefaultResourceFile = DefaultResourceFile;
            this.ParentFeatureFolder = ParentFeatureFolder;

            this.Url = new ResourceStringContainer(string.Empty, DefaultResourceFile, ParentFeatureFolder);

            this.ElementInfo = Element;
            this.ElementFileName = Element.ElementFileName;

            if (Element.XmlElementNode != null)
                this.PropXmlNode = Element.XmlElementNode;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Module name"), RefreshProperties(RefreshProperties.None)]
        public string Name
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Path"), RefreshProperties(RefreshProperties.None)]
        public string Path
        {
            get;
            set;
        }

        [CategoryAttribute("Properties"), DescriptionAttribute("Url"), RefreshProperties(RefreshProperties.None), TypeConverter(typeof(ResourceExpandableObjectConverter))]
        public ResourceStringContainer Url
        {
            get;
            set;
        }

        private string _SubType;
        [Browsable(false)]
        public string SubType
        {
            get { return _SubType; }
            set { _SubType = value; }
        }

        public override string ToString()
        {
            string s = string.Empty;
            if (string.IsNullOrEmpty(this.Name))
            {
                if (!string.IsNullOrEmpty(this.Path))
                    s = this.Path;
            }
            else
            {
                s = this.Name;
            }

            return "<Module> " + s;
        }
    }

}
